from django.urls import path, re_path
import blog.views as views
from blog.blog_article_api import BookList
from blog.article.views import ArticleDetail, ArticleDetailPost, ArticleForm
import blog.auth.views as auth_views
from blog.login.views import UserLogin
from blog.article.article_views import *

urlpatterns = [
     path('', views.index),
     path('articles/', BookList.as_view()),
     path('article/detail/',ArticleDetail.as_view()),
     #路径中带参数，使用正则表达式
     path('article/detail/<int:id>/',ArticleDetail.as_view(),name="article-detail"),
     #post请求参数
     path('article/detail/post/', ArticleDetailPost.as_view(), name="article-detail-post"),
     path('article/detail/post/<int:id>', ArticleDetailPost.as_view(), name="article-detail-post"),
     path('article/form/submit/', ArticleForm.as_view(), name="article-form"),
     #安全认证
     path('login/', auth_views.user_login, name='login'),
     path('protected/', auth_views.protected_page, name='protected_page'),
     path('logout/', auth_views.user_logout, name='logout'),
     path('to_login/', views.to_login, name='to_login'),
     path('user/login/', UserLogin.as_view(), name='user-login'),

     ############# 文章部分 ############
     path('article/to_article_list', to_article_list, name='to_article_list'),
     path('article/list', ArticleListView.as_view(), name='list'),
     #演示8.6 异步请求数据 lesson8.6
     path('article/to_article_list2', to_article_list2, name='to_article_list'),
]